﻿<%@ Control Language="C#" AutoEventWireup="true" Inherits="NopSolutions.NopCommerce.Web.Modules.SearchBoxControl"
    CodeBehind="SearchBox.ascx.cs" %>

    <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="js/jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>

    <script type="text/javascript">
        $(document).ready(function () {
//            $("[id$='txtSearchTerms']").autocomplete({
//                source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
//            });

            $.ajax({
                type: "POST",
                url: "WSDataService.asmx/GetStatesWithAbbr",
                dataType: "json",
                data: "{}",
                contentType: "application/json; charset=utf-8",
                success: function (data) {
                    $("[id$='txtSearchTerms']").autocomplete({
                        minLength: 0,
                        source: data.d,
                        focus: function (event, ui) {
                            $("[id$='txtSearchTerms']").val(ui.item.Name);
                            return false;
                        },
                        select: function (event, ui) {
                            $("[id$='txtSearchTerms']").val(ui.item.Name);
                            $('#selectedValue').text("Selected value:" + ui.item.Abbreviation);
                            return false;
                        }
                    });
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert(textStatus);
                }
            });
 
        });
    </script>
    <style type="text/css">
        .ui-menu 
        {
            text-align: left;
        } 
    </style>
<ul>
    <li>
        <asp:TextBox ID="txtSearchTerms" runat="server" SkinID="SearchBoxText" Text="<% $NopResources:Search.SearchStoreTooltip %>" />&nbsp;
    </li>
    <li>
        <asp:Button runat="server" ID="btnSearch" OnClick="btnSearch_Click" Text="<% $NopResources:Search.SearchButton %>"
            CssClass="searchboxbutton" CausesValidation="false" />
    </li>
</ul>
